#This component was recently contributed back to the Kamaelia project for inclusion and clean-up (02/11/2008)
#Based on code provided by Michael Sparks (MS-) and componentised by myself (Tyson Key/vmlemon).
#Now considered deprecated for Kamaelia 0.7.0 ;)

#http://code.google.com/p/kamaelia/source/browse/branches/merged/private_MPS_FileAppender/Kamaelia/Kamaelia/File/Append.py
#should be considered the current reference as of 02/11/2008

import Axon
class Append(Axon.Component.component):
     filename = "default.txt"
     def main(self):
         F = open(self.filename, "a")
         writing = True
         while writing:
              for chunk in self.Inbox("inbox"):
                   F.write(chunk)
		   F.flush
		   self.send(chunk, "outbox") # This line
              for M in self.Inbox("control"):
                   self.send(M, "signal")
                   writing = False
                   F.close()
              yield 1
